home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261a.zoo / info / gcc.info-8 < prev    next >
Encoding:
GNU Info File  |  1994-10-31  |  50.0 KB  |  1,221 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Published by the Free Software Foundation 675 Massachusetts Avenue
  7. Cambridge, MA 02139 USA
  8.  
  9.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  10.  
  11.    Permission is granted to make and distribute verbatim copies of this
  12. manual provided the copyright notice and this permission notice are
  13. preserved on all copies.
  14.  
  15.    Permission is granted to copy and distribute modified versions of
  16. this manual under the conditions for verbatim copying, provided also
  17. that the sections entitled "GNU General Public License" and "Protect
  18. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  19. original, and provided that the entire resulting derived work is
  20. distributed under the terms of a permission notice identical to this
  21. one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that the sections entitled "GNU General Public
  26. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  27. permission notice, may be included in translations approved by the Free
  28. Software Foundation instead of in the original English.
  29.  
  30. File: gcc.info,  Node: Case Ranges,  Next: Function Attributes,  Prev: Cast to Union,  Up: C Extensions
  31.  
  32. Case Ranges
  33. ===========
  34.  
  35.    You can specify a range of consecutive values in a single `case'
  36. label, like this:
  37.  
  38.      case LOW ... HIGH:
  39.  
  40. This has the same effect as the proper number of individual `case'
  41. labels, one for each integer value from LOW to HIGH, inclusive.
  42.  
  43.    This feature is especially useful for ranges of ASCII character
  44. codes:
  45.  
  46.      case 'A' ... 'Z':
  47.  
  48.    *Be careful:* Write spaces around the `...', for otherwise it may be
  49. parsed wrong when you use it with integer values.  For example, write
  50. this:
  51.  
  52.      case 1 ... 5:
  53.  
  54. rather than this:
  55.  
  56.      case 1...5:
  57.  
  58. File: gcc.info,  Node: Cast to Union,  Next: Case Ranges,  Prev: Labeled Elements,  Up: C Extensions
  59.  
  60. Cast to a Union Type
  61. ====================
  62.  
  63.    A cast to union type is similar to other casts, except that the type
  64. specified is a union type.  You can specify the type either with `union
  65. TAG' or with a typedef name.  A cast to union is actually a constructor
  66. though, not a cast, and hence does not yield an lvalue like normal
  67. casts.  (*Note Constructors::.)
  68.  
  69.    The types that may be cast to the union type are those of the members
  70. of the union.  Thus, given the following union and variables:
  71.  
  72.      union foo { int i; double d; };
  73.      int x;
  74.      double y;
  75.  
  76. both `x' and `y' can be cast to type `union' foo.
  77.  
  78.    Using the cast as the right-hand side of an assignment to a variable
  79. of union type is equivalent to storing in a member of the union:
  80.  
  81.      union foo u;
  82.      ...
  83.      u = (union foo) x  ==  u.i = x
  84.      u = (union foo) y  ==  u.d = y
  85.  
  86.    You can also use the union cast as a function argument:
  87.  
  88.      void hack (union foo);
  89.      ...
  90.      hack ((union foo) x);
  91.  
  92. File: gcc.info,  Node: Function Attributes,  Next: Function Prototypes,  Prev: Case Ranges,  Up: C Extensions
  93.  
  94. Declaring Attributes of Functions
  95. =================================
  96.  
  97.    In GNU C, you declare certain things about functions called in your
  98. program which help the compiler optimize function calls and check your
  99. code more carefully.
  100.  
  101.    The keyword `__attribute__' allows you to specify special attributes
  102. when making a declaration.  This keyword is followed by an attribute
  103. specification inside double parentheses.  Four attributes, `noreturn',
  104. `const', `format', and `section' are currently defined for functions.
  105. Other attributes, including `section' are supported for variables
  106. declarations (*note Variable Attributes::.).
  107.  
  108. `noreturn'
  109.      A few standard library functions, such as `abort' and `exit',
  110.      cannot return.  GNU CC knows this automatically.  Some programs
  111.      define their own functions that never return.  You can declare them
  112.      `noreturn' to tell the compiler this fact.  For example,
  113.  
  114.           void fatal () __attribute__ ((noreturn));
  115.           
  116.           void
  117.           fatal (...)
  118.           {
  119.             ... /* Print error message. */ ...
  120.             exit (1);
  121.           }
  122.  
  123.      The `noreturn' keyword tells the compiler to assume that `fatal'
  124.      cannot return.  It can then optimize without regard to what would
  125.      happen if `fatal' ever did return.  This makes slightly better
  126.      code.  More importantly, it helps avoid spurious warnings of
  127.      uninitialized variables.
  128.  
  129.      Do not assume that registers saved by the calling function are
  130.      restored before calling the `noreturn' function.
  131.  
  132.      It does not make sense for a `noreturn' function to have a return
  133.      type other than `void'.
  134.  
  135.      The attribute `noreturn' is not implemented in GNU C versions
  136.      earlier than 2.5.  An alternative way to declare that a function
  137.      does not return, which works in the current version and in some
  138.      older versions, is as follows:
  139.  
  140.           typedef void voidfn ();
  141.           
  142.           volatile voidfn fatal;
  143.  
  144. `const'
  145.      Many functions do not examine any values except their arguments,
  146.      and have no effects except the return value.  Such a function can
  147.      be subject to common subexpression elimination and loop
  148.      optimization just as an arithmetic operator would be.  These
  149.      functions should be declared with the attribute `const'.  For
  150.      example,
  151.  
  152.           int square (int) __attribute__ ((const));
  153.  
  154.      says that the hypothetical function `square' is safe to call fewer
  155.      times than the program says.
  156.  
  157.      The attribute `const' is not implemented in GNU C versions earlier
  158.      than 2.5.  An alternative way to declare that a function has no
  159.      side effects, which works in the current version and in some older
  160.      versions, is as follows:
  161.  
  162.           typedef int intfn ();
  163.           
  164.           extern const intfn square;
  165.  
  166.      Note that a function that has pointer arguments and examines the
  167.      data pointed to must *not* be declared `const'.  Likewise, a
  168.      function that calls a non-`const' function usually must not be
  169.      `const'.  It does not make sense for a `const' function to return
  170.      `void'.
  171.  
  172. `format (ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)'
  173.      The `format' attribute specifies that a function takes `printf' or
  174.      `scanf' style arguments which should be type-checked against a
  175.      format string.  For example, the declaration:
  176.  
  177.           extern int
  178.           my_printf (void *my_object, const char *my_format, ...)
  179.                 __attribute__ ((format (printf, 2, 3)));
  180.  
  181.      causes the compiler to check the arguments in calls to `my_printf'
  182.      for consistency with the `printf' style format string argument
  183.      `my_format'.
  184.  
  185.      The parameter ARCHETYPE determines how the format string is
  186.      interpreted, and should be either `printf' or `scanf'.  The
  187.      parameter STRING-INDEX specifies which argument is the format
  188.      string argument (starting from 1), while FIRST-TO-CHECK is the
  189.      number of the first argument to check against the format string.
  190.      For functions where the arguments are not available to be checked
  191.      (such as `vprintf'), specify the third parameter as zero.  In this
  192.      case the compiler only checks the format string for consistency.
  193.  
  194.      In the example above, the format string (`my_format') is the second
  195.      argument of the function `my_print', and the arguments to check
  196.      start with the third argument, so the correct parameters for the
  197.      format attribute are 2 and 3.
  198.  
  199.      The `format' attribute allows you to identify your own functions
  200.      which take format strings as arguments, so that GNU CC can check
  201.      the calls to these functions for errors.  The compiler always
  202.      checks formats for the ANSI library functions `printf', `fprintf',
  203.      `sprintf', `scanf', `fscanf', `sscanf', `vprintf', `vfprintf' and
  204.      `vsprintf' whenever such warnings are requested (using
  205.      `-Wformat'), so there is no need to modify the header file
  206.      `stdio.h'.
  207.  
  208. `section ("section-name")'
  209.      Normally, the compiler places the code it generates in the `text'
  210.      section.  Sometimes, however, you need additional sections, or you
  211.      need certain particular functions to appear in special sections.
  212.      The `section' attribute specifies that a function lives in a
  213.      particular section.  For example, the declaration:
  214.  
  215.           extern void foobar (void) __attribute__ ((section (".init")));
  216.  
  217.      puts the function `foobar' in the `.init' section.
  218.  
  219.      Some file formats do not support arbitrary sections so the
  220.      `section' attribute is not available on all platforms.  If you
  221.      need to map the entire contents of a module to a particular
  222.      section, consider using the facilities of the linker instead.
  223.  
  224.    You can specify multiple attributes in a declaration by separating
  225. them by commas within the double parentheses or by immediately
  226. following an attribute declaration with another attribute declaration.
  227.  
  228.    Some people object to the `__attribute__' feature, suggesting that
  229. ANSI C's `#pragma' should be used instead.  There are two reasons for
  230. not doing this.
  231.  
  232.   1. It is impossible to generate `#pragma' commands from a macro.
  233.  
  234.   2. There is no telling what the same `#pragma' might mean in another
  235.      compiler.
  236.  
  237.    These two reasons apply to almost any application that might be
  238. proposed for `#pragma'.  It is basically a mistake to use `#pragma' for
  239. *anything*.
  240.  
  241. File: gcc.info,  Node: Function Prototypes,  Next: Dollar Signs,  Prev: Function Attributes,  Up: C Extensions
  242.  
  243. Prototypes and Old-Style Function Definitions
  244. =============================================
  245.  
  246.    GNU C extends ANSI C to allow a function prototype to override a
  247. later old-style non-prototype definition.  Consider the following
  248. example:
  249.  
  250.      /* Use prototypes unless the compiler is old-fashioned.  */
  251.      #if __STDC__
  252.      #define P(x) x
  253.      #else
  254.      #define P(x) ()
  255.      #endif
  256.      
  257.      /* Prototype function declaration.  */
  258.      int isroot P((uid_t));
  259.      
  260.      /* Old-style function definition.  */
  261.      int
  262.      isroot (x)   /* ??? lossage here ??? */
  263.           uid_t x;
  264.      {
  265.        return x == 0;
  266.      }
  267.  
  268.    Suppose the type `uid_t' happens to be `short'.  ANSI C does not
  269. allow this example, because subword arguments in old-style
  270. non-prototype definitions are promoted.  Therefore in this example the
  271. function definition's argument is really an `int', which does not match
  272. the prototype argument type of `short'.
  273.  
  274.    This restriction of ANSI C makes it hard to write code that is
  275. portable to traditional C compilers, because the programmer does not
  276. know whether the `uid_t' type is `short', `int', or `long'.  Therefore,
  277. in cases like these GNU C allows a prototype to override a later
  278. old-style definition.  More precisely, in GNU C, a function prototype
  279. argument type overrides the argument type specified by a later
  280. old-style definition if the former type is the same as the latter type
  281. before promotion.  Thus in GNU C the above example is equivalent to the
  282. following:
  283.  
  284.      int isroot (uid_t);
  285.      
  286.      int
  287.      isroot (uid_t x)
  288.      {
  289.        return x == 0;
  290.      }
  291.  
  292. File: gcc.info,  Node: Dollar Signs,  Next: Character Escapes,  Prev: Function Prototypes,  Up: C Extensions
  293.  
  294. Dollar Signs in Identifier Names
  295. ================================
  296.  
  297.    In GNU C, you may use dollar signs in identifier names.  This is
  298. because many traditional C implementations allow such identifiers.
  299.  
  300.    On some machines, dollar signs are allowed in identifiers if you
  301. specify `-traditional'.  On a few systems they are allowed by default,
  302. even if you do not use `-traditional'.  But they are never allowed if
  303. you specify `-ansi'.
  304.  
  305.    There are certain ANSI C programs (obscure, to be sure) that would
  306. compile incorrectly if dollar signs were permitted in identifiers.  For
  307. example:
  308.  
  309.      #define foo(a) #a
  310.      #define lose(b) foo (b)
  311.      #define test$
  312.      lose (test)
  313.  
  314. File: gcc.info,  Node: Character Escapes,  Next: Variable Attributes,  Prev: Dollar Signs,  Up: C Extensions
  315.  
  316. The Character ESC in Constants
  317. ==============================
  318.  
  319.    You can use the sequence `\e' in a string or character constant to
  320. stand for the ASCII character ESC.
  321.  
  322. File: gcc.info,  Node: Alignment,  Next: Inline,  Prev: Variable Attributes,  Up: C Extensions
  323.  
  324. Inquiring on Alignment of Types or Variables
  325. ============================================
  326.  
  327.    The keyword `__alignof__' allows you to inquire about how an object
  328. is aligned, or the minimum alignment usually required by a type.  Its
  329. syntax is just like `sizeof'.
  330.  
  331.    For example, if the target machine requires a `double' value to be
  332. aligned on an 8-byte boundary, then `__alignof__ (double)' is 8.  This
  333. is true on many RISC machines.  On more traditional machine designs,
  334. `__alignof__ (double)' is 4 or even 2.
  335.  
  336.    Some machines never actually require alignment; they allow reference
  337. to any data type even at an odd addresses.  For these machines,
  338. `__alignof__' reports the *recommended* alignment of a type.
  339.  
  340.    When the operand of `__alignof__' is an lvalue rather than a type,
  341. the value is the largest alignment that the lvalue is known to have.
  342. It may have this alignment as a result of its data type, or because it
  343. is part of a structure and inherits alignment from that structure.  For
  344. example, after this declaration:
  345.  
  346.      struct foo { int x; char y; } foo1;
  347.  
  348. the value of `__alignof__ (foo1.y)' is probably 2 or 4, the same as
  349. `__alignof__ (int)', even though the data type of `foo1.y' does not
  350. itself demand any alignment.
  351.  
  352.    A related feature which lets you specify the alignment of an object
  353. is `__attribute__ ((aligned (ALIGNMENT)))'; see the following section.
  354.  
  355. File: gcc.info,  Node: Variable Attributes,  Next: Alignment,  Prev: Character Escapes,  Up: C Extensions
  356.  
  357. Specifying Attributes of Variables
  358. ==================================
  359.  
  360.    The keyword `__attribute__' allows you to specify special attributes
  361. of variables or structure fields.  This keyword is followed by an
  362. attribute specification inside double parentheses.  Four attributes are
  363. currently defined for variables: `aligned', `mode', `packed', and
  364. `section'.  Other attributes are defined for functions, and thus not
  365. documented here; see *Note Function Attributes::.
  366.  
  367. `aligned (ALIGNMENT)'
  368.      This attribute specifies a minimum alignment for the variable or
  369.      structure field, measured in bytes.  For example, the declaration:
  370.  
  371.           int x __attribute__ ((aligned (16))) = 0;
  372.  
  373.      causes the compiler to allocate the global variable `x' on a
  374.      16-byte boundary.  On a 68040, this could be used in conjunction
  375.      with an `asm' expression to access the `move16' instruction which
  376.      requires 16-byte aligned operands.
  377.  
  378.      You can also specify the alignment of structure fields.  For
  379.      example, to create a double-word aligned `int' pair, you could
  380.      write:
  381.  
  382.           struct foo { int x[2] __attribute__ ((aligned (8))); };
  383.  
  384.      This is an alternative to creating a union with a `double' member
  385.      that forces the union to be double-word aligned.
  386.  
  387.      It is not possible to specify the alignment of functions; the
  388.      alignment of functions is determined by the machine's requirements
  389.      and cannot be changed.  You cannot specify alignment for a typedef
  390.      name because such a name is just an alias, not a distinct type.
  391.  
  392.      The `aligned' attribute can only increase the alignment; but you
  393.      can decrease it by specifying `packed' as well.  See below.
  394.  
  395.      The linker of your operating system imposes a maximum alignment.
  396.      If the linker aligns each object file on a four byte boundary,
  397.      then it is beyond the compiler's power to cause anything to be
  398.      aligned to a larger boundary than that.  For example, if  the
  399.      linker happens to put this object file at address 136 (eight more
  400.      than a multiple of 64), then the compiler cannot guarantee an
  401.      alignment of more than 8 just by aligning variables in the object
  402.      file.
  403.  
  404. `mode (MODE)'
  405.      This attribute specifies the data type for the
  406.      declaration--whichever type corresponds to the mode MODE.  This in
  407.      effect lets you request an integer or floating point type
  408.      according to its width.
  409.  
  410. `packed'
  411.      The `packed' attribute specifies that a variable or structure field
  412.      should have the smallest possible alignment--one byte for a
  413.      variable, and one bit for a field, unless you specify a larger
  414.      value with the `aligned' attribute.
  415.  
  416.      Here is a structure in which the field `x' is packed, so that it
  417.      immediately follows `a':
  418.  
  419.           struct foo
  420.           {
  421.             char a;
  422.             int x[2] __attribute__ ((packed));
  423.           };
  424.  
  425. `section ("section-name")'
  426.      Normally, the compiler places the objects it generates in sections
  427.      like `data' and `bss'.  Sometimes, however, you need additional
  428.      sections, or you need certain particular variables to appear in
  429.      special sections, for example to map to special hardware.  The
  430.      `section' attribute specifies that a variable (or function) lives
  431.      in a particular section.  For example, this small program uses
  432.      several specific section names:
  433.  
  434.           struct duart a __attribute__ ((section ("DUART_A"))) = { 0 };
  435.           struct duart b __attribute__ ((section ("DUART_B"))) = { 0 };
  436.           char stack[10000] __attribute__ ((section ("STACK"))) = { 0 };
  437.           int init_data_copy __attribute__ ((section ("INITDATACOPY"))) = 0;
  438.           
  439.           main()
  440.           {
  441.             /* Initialize stack pointer */
  442.             init_sp (stack + sizeof (stack));
  443.           
  444.             /* Initialize initialized data */
  445.             memcpy (&init_data_copy, &data, &edata - &data);
  446.           
  447.             /* Turn on the serial ports */
  448.             init_duart (&a);
  449.             init_duart (&b);
  450.           }
  451.  
  452.      Use the `section' attribute with an *initialized* definition of a
  453.      *global* variable, as shown in the example.  GNU CC issues a
  454.      warning and otherwise ignores the `section' attribute in
  455.      uninitialized variable declarations.
  456.  
  457.      You may only use the `section' attribute with a fully initialized
  458.      global definition because of the way linkers work.  The linker
  459.      requires each object be defined once, with the exception that
  460.      uninitialized variables tentatively go in the `common' (or `bss')
  461.      section and can be multiply "defined".
  462.  
  463.      Some file formats do not support arbitrary sections so the
  464.      `section' attribute is not available on all platforms.  If you
  465.      need to map the entire contents of a module to a particular
  466.      section, consider using the facilities of the linker instead.
  467.  
  468.    To specify multiple attributes, separate them by commas within the
  469. double parentheses: for example, `__attribute__ ((aligned (16),
  470. packed))'.
  471.  
  472. File: gcc.info,  Node: Inline,  Next: Extended Asm,  Prev: Alignment,  Up: C Extensions
  473.  
  474. An Inline Function is As Fast As a Macro
  475. ========================================
  476.  
  477.    By declaring a function `inline', you can direct GNU CC to integrate
  478. that function's code into the code for its callers.  This makes
  479. execution faster by eliminating the function-call overhead; in
  480. addition, if any of the actual argument values are constant, their known
  481. values may permit simplifications at compile time so that not all of the
  482. inline function's code needs to be included.  The effect on code size is
  483. less predictable; object code may be larger or smaller with function
  484. inlining, depending on the particular case.  Inlining of functions is an
  485. optimization and it really "works" only in optimizing compilation.  If
  486. you don't use `-O', no function is really inline.
  487.  
  488.    To declare a function inline, use the `inline' keyword in its
  489. declaration, like this:
  490.  
  491.      inline int
  492.      inc (int *a)
  493.      {
  494.        (*a)++;
  495.      }
  496.  
  497.    (If you are writing a header file to be included in ANSI C programs,
  498. write `__inline__' instead of `inline'.  *Note Alternate Keywords::.)
  499.  
  500.    You can also make all "simple enough" functions inline with the
  501. option `-finline-functions'.  Note that certain usages in a function
  502. definition can make it unsuitable for inline substitution.
  503.  
  504.    For C++ programs, GNU CC automatically inlines member functions even
  505. if they are not explicitly declared `inline'.  (You can override this
  506. with `-fno-default-inline'; *note Options Controlling C++ Dialect: C++
  507. Dialect Options..)
  508.  
  509.    When a function is both inline and `static', if all calls to the
  510. function are integrated into the caller, and the function's address is
  511. never used, then the function's own assembler code is never referenced.
  512. In this case, GNU CC does not actually output assembler code for the
  513. function, unless you specify the option `-fkeep-inline-functions'.
  514. Some calls cannot be integrated for various reasons (in particular,
  515. calls that precede the function's definition cannot be integrated, and
  516. neither can recursive calls within the definition).  If there is a
  517. nonintegrated call, then the function is compiled to assembler code as
  518. usual.  The function must also be compiled as usual if the program
  519. refers to its address, because that can't be inlined.
  520.  
  521.    When an inline function is not `static', then the compiler must
  522. assume that there may be calls from other source files; since a global
  523. symbol can be defined only once in any program, the function must not
  524. be defined in the other source files, so the calls therein cannot be
  525. integrated.  Therefore, a non-`static' inline function is always
  526. compiled on its own in the usual fashion.
  527.  
  528.    If you specify both `inline' and `extern' in the function
  529. definition, then the definition is used only for inlining.  In no case
  530. is the function compiled on its own, not even if you refer to its
  531. address explicitly.  Such an address becomes an external reference, as
  532. if you had only declared the function, and had not defined it.
  533.  
  534.    This combination of `inline' and `extern' has almost the effect of a
  535. macro.  The way to use it is to put a function definition in a header
  536. file with these keywords, and put another copy of the definition
  537. (lacking `inline' and `extern') in a library file.  The definition in
  538. the header file will cause most calls to the function to be inlined.
  539. If any uses of the function remain, they will refer to the single copy
  540. in the library.
  541.  
  542.    GNU C does not inline any functions when not optimizing.  It is not
  543. clear whether it is better to inline or not, in this case, but we found
  544. that a correct implementation when not optimizing was difficult.  So we
  545. did the easy thing, and turned it off.
  546.  
  547. File: gcc.info,  Node: Extended Asm,  Next: Asm Labels,  Prev: Inline,  Up: C Extensions
  548.  
  549. Assembler Instructions with C Expression Operands
  550. =================================================
  551.  
  552.    In an assembler instruction using `asm', you can now specify the
  553. operands of the instruction using C expressions.  This means no more
  554. guessing which registers or memory locations will contain the data you
  555. want to use.
  556.  
  557.    You must specify an assembler instruction template much like what
  558. appears in a machine description, plus an operand constraint string for
  559. each operand.
  560.  
  561.    For example, here is how to use the 68881's `fsinx' instruction:
  562.  
  563.      asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
  564.  
  565. Here `angle' is the C expression for the input operand while `result'
  566. is that of the output operand.  Each has `"f"' as its operand
  567. constraint, saying that a floating point register is required.  The `='
  568. in `=f' indicates that the operand is an output; all output operands'
  569. constraints must use `='.  The constraints use the same language used
  570. in the machine description (*note Constraints::.).
  571.  
  572.    Each operand is described by an operand-constraint string followed
  573. by the C expression in parentheses.  A colon separates the assembler
  574. template from the first output operand, and another separates the last
  575. output operand from the first input, if any.  Commas separate output
  576. operands and separate inputs.  The total number of operands is limited
  577. to ten or to the maximum number of operands in any instruction pattern
  578. in the machine description, whichever is greater.
  579.  
  580.    If there are no output operands, and there are input operands, then
  581. there must be two consecutive colons surrounding the place where the
  582. output operands would go.
  583.  
  584.    Output operand expressions must be lvalues; the compiler can check
  585. this.  The input operands need not be lvalues.  The compiler cannot
  586. check whether the operands have data types that are reasonable for the
  587. instruction being executed.  It does not parse the assembler
  588. instruction template and does not know what it means, or whether it is
  589. valid assembler input.  The extended `asm' feature is most often used
  590. for machine instructions that the compiler itself does not know exist.
  591.  
  592.    The output operands must be write-only; GNU CC will assume that the
  593. values in these operands before the instruction are dead and need not be
  594. generated.  Extended asm does not support input-output or read-write
  595. operands.  For this reason, the constraint character `+', which
  596. indicates such an operand, may not be used.
  597.  
  598.    When the assembler instruction has a read-write operand, or an
  599. operand in which only some of the bits are to be changed, you must
  600. logically split its function into two separate operands, one input
  601. operand and one write-only output operand.  The connection between them
  602. is expressed by constraints which say they need to be in the same
  603. location when the instruction executes.  You can use the same C
  604. expression for both operands, or different expressions.  For example,
  605. here we write the (fictitious) `combine' instruction with `bar' as its
  606. read-only source operand and `foo' as its read-write destination:
  607.  
  608.      asm ("combine %2,%0" : "=r" (foo) : "0" (foo), "g" (bar));
  609.  
  610. The constraint `"0"' for operand 1 says that it must occupy the same
  611. location as operand 0.  A digit in constraint is allowed only in an
  612. input operand, and it must refer to an output operand.
  613.  
  614.    Only a digit in the constraint can guarantee that one operand will
  615. be in the same place as another.  The mere fact that `foo' is the value
  616. of both operands is not enough to guarantee that they will be in the
  617. same place in the generated assembler code.  The following would not
  618. work:
  619.  
  620.      asm ("combine %2,%0" : "=r" (foo) : "r" (foo), "g" (bar));
  621.  
  622.    Various optimizations or reloading could cause operands 0 and 1 to
  623. be in different registers; GNU CC knows no reason not to do so.  For
  624. example, the compiler might find a copy of the value of `foo' in one
  625. register and use it for operand 1, but generate the output operand 0 in
  626. a different register (copying it afterward to `foo''s own address).  Of
  627. course, since the register for operand 1 is not even mentioned in the
  628. assembler code, the result will not work, but GNU CC can't tell that.
  629.  
  630.    Some instructions clobber specific hard registers.  To describe
  631. this, write a third colon after the input operands, followed by the
  632. names of the clobbered hard registers (given as strings).  Here is a
  633. realistic example for the Vax:
  634.  
  635.      asm volatile ("movc3 %0,%1,%2"
  636.                    : /* no outputs */
  637.                    : "g" (from), "g" (to), "g" (count)
  638.                    : "r0", "r1", "r2", "r3", "r4", "r5");
  639.  
  640.    If you refer to a particular hardware register from the assembler
  641. code, then you will probably have to list the register after the third
  642. colon to tell the compiler that the register's value is modified.  In
  643. many assemblers, the register names begin with `%'; to produce one `%'
  644. in the assembler code, you must write `%%' in the input.
  645.  
  646.    If your assembler instruction can alter the condition code register,
  647. add `cc' to the list of clobbered registers.  GNU CC on some machines
  648. represents the condition codes as a specific hardware register; `cc'
  649. serves to name this register.  On other machines, the condition code is
  650. handled differently, and specifying `cc' has no effect.  But it is
  651. valid no matter what the machine.
  652.  
  653.    If your assembler instruction modifies memory in an unpredictable
  654. fashion, add `memory' to the list of clobbered registers.  This will
  655. cause GNU CC to not keep memory values cached in registers across the
  656. assembler instruction.
  657.  
  658.    You can put multiple assembler instructions together in a single
  659. `asm' template, separated either with newlines (written as `\n') or with
  660. semicolons if the assembler allows such semicolons.  The GNU assembler
  661. allows semicolons and all Unix assemblers seem to do so.  The input
  662. operands are guaranteed not to use any of the clobbered registers, and
  663. neither will the output operands' addresses, so you can read and write
  664. the clobbered registers as many times as you like.  Here is an example
  665. of multiple instructions in a template; it assumes that the subroutine
  666. `_foo' accepts arguments in registers 9 and 10:
  667.  
  668.      asm ("movl %0,r9;movl %1,r10;call _foo"
  669.           : /* no outputs */
  670.           : "g" (from), "g" (to)
  671.           : "r9", "r10");
  672.  
  673.    Unless an output operand has the `&' constraint modifier, GNU CC may
  674. allocate it in the same register as an unrelated input operand, on the
  675. assumption that the inputs are consumed before the outputs are produced.
  676. This assumption may be false if the assembler code actually consists of
  677. more than one instruction.  In such a case, use `&' for each output
  678. operand that may not overlap an input.  *Note Modifiers::.
  679.  
  680.    If you want to test the condition code produced by an assembler
  681. instruction, you must include a branch and a label in the `asm'
  682. construct, as follows:
  683.  
  684.      asm ("clr %0;frob %1;beq 0f;mov #1,%0;0:"
  685.           : "g" (result)
  686.           : "g" (input));
  687.  
  688. This assumes your assembler supports local labels, as the GNU assembler
  689. and most Unix assemblers do.
  690.  
  691.    Speaking of labels, jumps from one `asm' to another are not
  692. supported.  The compiler's optimizers do not know about these jumps,
  693. and therefore they cannot take account of them when deciding how to
  694. optimize.
  695.  
  696.    Usually the most convenient way to use these `asm' instructions is to
  697. encapsulate them in macros that look like functions.  For example,
  698.  
  699.      #define sin(x)       \
  700.      ({ double __value, __arg = (x);   \
  701.         asm ("fsinx %1,%0": "=f" (__value): "f" (__arg));  \
  702.         __value; })
  703.  
  704. Here the variable `__arg' is used to make sure that the instruction
  705. operates on a proper `double' value, and to accept only those arguments
  706. `x' which can convert automatically to a `double'.
  707.  
  708.    Another way to make sure the instruction operates on the correct
  709. data type is to use a cast in the `asm'.  This is different from using a
  710. variable `__arg' in that it converts more different types.  For
  711. example, if the desired type were `int', casting the argument to `int'
  712. would accept a pointer with no complaint, while assigning the argument
  713. to an `int' variable named `__arg' would warn about using a pointer
  714. unless the caller explicitly casts it.
  715.  
  716.    If an `asm' has output operands, GNU CC assumes for optimization
  717. purposes that the instruction has no side effects except to change the
  718. output operands.  This does not mean that instructions with a side
  719. effect cannot be used, but you must be careful, because the compiler
  720. may eliminate them if the output operands aren't used, or move them out
  721. of loops, or replace two with one if they constitute a common
  722. subexpression.  Also, if your instruction does have a side effect on a
  723. variable that otherwise appears not to change, the old value of the
  724. variable may be reused later if it happens to be found in a register.
  725.  
  726.    You can prevent an `asm' instruction from being deleted, moved
  727. significantly, or combined, by writing the keyword `volatile' after the
  728. `asm'.  For example:
  729.  
  730.      #define set_priority(x)  \
  731.      asm volatile ("set_priority %0": /* no outputs */ : "g" (x))
  732.  
  733. An instruction without output operands will not be deleted or moved
  734. significantly, regardless, unless it is unreachable.
  735.  
  736.    Note that even a volatile `asm' instruction can be moved in ways
  737. that appear insignificant to the compiler, such as across jump
  738. instructions.  You can't expect a sequence of volatile `asm'
  739. instructions to remain perfectly consecutive.  If you want consecutive
  740. output, use a single `asm'.
  741.  
  742.    It is a natural idea to look for a way to give access to the
  743. condition code left by the assembler instruction.  However, when we
  744. attempted to implement this, we found no way to make it work reliably.
  745. The problem is that output operands might need reloading, which would
  746. result in additional following "store" instructions.  On most machines,
  747. these instructions would alter the condition code before there was time
  748. to test it.  This problem doesn't arise for ordinary "test" and
  749. "compare" instructions because they don't have any output operands.
  750.  
  751.    If you are writing a header file that should be includable in ANSI C
  752. programs, write `__asm__' instead of `asm'.  *Note Alternate Keywords::.
  753.  
  754. File: gcc.info,  Node: Asm Labels,  Next: Explicit Reg Vars,  Prev: Extended Asm,  Up: C Extensions
  755.  
  756. Controlling Names Used in Assembler Code
  757. ========================================
  758.  
  759.    You can specify the name to be used in the assembler code for a C
  760. function or variable by writing the `asm' (or `__asm__') keyword after
  761. the declarator as follows:
  762.  
  763.      int foo asm ("myfoo") = 2;
  764.  
  765. This specifies that the name to be used for the variable `foo' in the
  766. assembler code should be `myfoo' rather than the usual `_foo'.
  767.  
  768.    On systems where an underscore is normally prepended to the name of
  769. a C function or variable, this feature allows you to define names for
  770. the linker that do not start with an underscore.
  771.  
  772.    You cannot use `asm' in this way in a function *definition*; but you
  773. can get the same effect by writing a declaration for the function
  774. before its definition and putting `asm' there, like this:
  775.  
  776.      extern func () asm ("FUNC");
  777.      
  778.      func (x, y)
  779.           int x, y;
  780.      ...
  781.  
  782.    It is up to you to make sure that the assembler names you choose do
  783. not conflict with any other assembler symbols.  Also, you must not use a
  784. register name; that would produce completely invalid assembler code.
  785. GNU CC does not as yet have the ability to store static variables in
  786. registers.  Perhaps that will be added.
  787.  
  788. File: gcc.info,  Node: Explicit Reg Vars,  Next: Alternate Keywords,  Prev: Asm Labels,  Up: C Extensions
  789.  
  790. Variables in Specified Registers
  791. ================================
  792.  
  793.    GNU C allows you to put a few global variables into specified
  794. hardware registers.  You can also specify the register in which an
  795. ordinary register variable should be allocated.
  796.  
  797.    * Global register variables reserve registers throughout the program.
  798.      This may be useful in programs such as programming language
  799.      interpreters which have a couple of global variables that are
  800.      accessed very often.
  801.  
  802.    * Local register variables in specific registers do not reserve the
  803.      registers.  The compiler's data flow analysis is capable of
  804.      determining where the specified registers contain live values, and
  805.      where they are available for other uses.
  806.  
  807.      These local variables are sometimes convenient for use with the
  808.      extended `asm' feature (*note Extended Asm::.), if you want to
  809.      write one output of the assembler instruction directly into a
  810.      particular register.  (This will work provided the register you
  811.      specify fits the constraints specified for that operand in the
  812.      `asm'.)
  813.  
  814. * Menu:
  815.  
  816. * Global Reg Vars::
  817. * Local Reg Vars::
  818.  
  819. File: gcc.info,  Node: Global Reg Vars,  Next: Local Reg Vars,  Up: Explicit Reg Vars
  820.  
  821. Defining Global Register Variables
  822. ----------------------------------
  823.  
  824.    You can define a global register variable in GNU C like this:
  825.  
  826.      register int *foo asm ("a5");
  827.  
  828. Here `a5' is the name of the register which should be used.  Choose a
  829. register which is normally saved and restored by function calls on your
  830. machine, so that library routines will not clobber it.
  831.  
  832.    Naturally the register name is cpu-dependent, so you would need to
  833. conditionalize your program according to cpu type.  The register `a5'
  834. would be a good choice on a 68000 for a variable of pointer type.  On
  835. machines with register windows, be sure to choose a "global" register
  836. that is not affected magically by the function call mechanism.
  837.  
  838.    In addition, operating systems on one type of cpu may differ in how
  839. they name the registers; then you would need additional conditionals.
  840. For example, some 68000 operating systems call this register `%a5'.
  841.  
  842.    Eventually there may be a way of asking the compiler to choose a
  843. register automatically, but first we need to figure out how it should
  844. choose and how to enable you to guide the choice.  No solution is
  845. evident.
  846.  
  847.    Defining a global register variable in a certain register reserves
  848. that register entirely for this use, at least within the current
  849. compilation.  The register will not be allocated for any other purpose
  850. in the functions in the current compilation.  The register will not be
  851. saved and restored by these functions.  Stores into this register are
  852. never deleted even if they would appear to be dead, but references may
  853. be deleted or moved or simplified.
  854.  
  855.    It is not safe to access the global register variables from signal
  856. handlers, or from more than one thread of control, because the system
  857. library routines may temporarily use the register for other things
  858. (unless you recompile them specially for the task at hand).
  859.  
  860.    It is not safe for one function that uses a global register variable
  861. to call another such function `foo' by way of a third function `lose'
  862. that was compiled without knowledge of this variable (i.e. in a
  863. different source file in which the variable wasn't declared).  This is
  864. because `lose' might save the register and put some other value there.
  865. For example, you can't expect a global register variable to be
  866. available in the comparison-function that you pass to `qsort', since
  867. `qsort' might have put something else in that register.  (If you are
  868. prepared to recompile `qsort' with the same global register variable,
  869. you can solve this problem.)
  870.  
  871.    If you want to recompile `qsort' or other source files which do not
  872. actually use your global register variable, so that they will not use
  873. that register for any other purpose, then it suffices to specify the
  874. compiler option `-ffixed-REG'.  You need not actually add a global
  875. register declaration to their source code.
  876.  
  877.    A function which can alter the value of a global register variable
  878. cannot safely be called from a function compiled without this variable,
  879. because it could clobber the value the caller expects to find there on
  880. return.  Therefore, the function which is the entry point into the part
  881. of the program that uses the global register variable must explicitly
  882. save and restore the value which belongs to its caller.
  883.  
  884.    On most machines, `longjmp' will restore to each global register
  885. variable the value it had at the time of the `setjmp'.  On some
  886. machines, however, `longjmp' will not change the value of global
  887. register variables.  To be portable, the function that called `setjmp'
  888. should make other arrangements to save the values of the global register
  889. variables, and to restore them in a `longjmp'.  This way, the same
  890. thing will happen regardless of what `longjmp' does.
  891.  
  892.    All global register variable declarations must precede all function
  893. definitions.  If such a declaration could appear after function
  894. definitions, the declaration would be too late to prevent the register
  895. from being used for other purposes in the preceding functions.
  896.  
  897.    Global register variables may not have initial values, because an
  898. executable file has no means to supply initial contents for a register.
  899.  
  900.    On the Sparc, there are reports that g3 ... g7 are suitable
  901. registers, but certain library functions, such as `getwd', as well as
  902. the subroutines for division and remainder, modify g3 and g4.  g1 and
  903. g2 are local temporaries.
  904.  
  905.    On the 68000, a2 ... a5 should be suitable, as should d2 ... d7.  Of
  906. course, it will not do to use more than a few of those.
  907.  
  908. File: gcc.info,  Node: Local Reg Vars,  Prev: Global Reg Vars,  Up: Explicit Reg Vars
  909.  
  910. Specifying Registers for Local Variables
  911. ----------------------------------------
  912.  
  913.    You can define a local register variable with a specified register
  914. like this:
  915.  
  916.      register int *foo asm ("a5");
  917.  
  918. Here `a5' is the name of the register which should be used.  Note that
  919. this is the same syntax used for defining global register variables,
  920. but for a local variable it would appear within a function.
  921.  
  922.    Naturally the register name is cpu-dependent, but this is not a
  923. problem, since specific registers are most often useful with explicit
  924. assembler instructions (*note Extended Asm::.).  Both of these things
  925. generally require that you conditionalize your program according to cpu
  926. type.
  927.  
  928.    In addition, operating systems on one type of cpu may differ in how
  929. they name the registers; then you would need additional conditionals.
  930. For example, some 68000 operating systems call this register `%a5'.
  931.  
  932.    Eventually there may be a way of asking the compiler to choose a
  933. register automatically, but first we need to figure out how it should
  934. choose and how to enable you to guide the choice.  No solution is
  935. evident.
  936.  
  937.    Defining such a register variable does not reserve the register; it
  938. remains available for other uses in places where flow control determines
  939. the variable's value is not live.  However, these registers are made
  940. unavailable for use in the reload pass.  I would not be surprised if
  941. excessive use of this feature leaves the compiler too few available
  942. registers to compile certain functions.
  943.  
  944. File: gcc.info,  Node: Alternate Keywords,  Next: Incomplete Enums,  Prev: Explicit Reg Vars,  Up: C Extensions
  945.  
  946. Alternate Keywords
  947. ==================
  948.  
  949.    The option `-traditional' disables certain keywords; `-ansi'
  950. disables certain others.  This causes trouble when you want to use GNU C
  951. extensions, or ANSI C features, in a general-purpose header file that
  952. should be usable by all programs, including ANSI C programs and
  953. traditional ones.  The keywords `asm', `typeof' and `inline' cannot be
  954. used since they won't work in a program compiled with `-ansi', while
  955. the keywords `const', `volatile', `signed', `typeof' and `inline' won't
  956. work in a program compiled with `-traditional'.
  957.  
  958.    The way to solve these problems is to put `__' at the beginning and
  959. end of each problematical keyword.  For example, use `__asm__' instead
  960. of `asm', `__const__' instead of `const', and `__inline__' instead of
  961. `inline'.
  962.  
  963.    Other C compilers won't accept these alternative keywords; if you
  964. want to compile with another compiler, you can define the alternate
  965. keywords as macros to replace them with the customary keywords.  It
  966. looks like this:
  967.  
  968.      #ifndef __GNUC__
  969.      #define __asm__ asm
  970.      #endif
  971.  
  972.    `-pedantic' causes warnings for many GNU C extensions.  You can
  973. prevent such warnings within one expression by writing `__extension__'
  974. before the expression.  `__extension__' has no effect aside from this.
  975.  
  976. File: gcc.info,  Node: Incomplete Enums,  Next: Function Names,  Prev: Alternate Keywords,  Up: C Extensions
  977.  
  978. Incomplete `enum' Types
  979. =======================
  980.  
  981.    You can define an `enum' tag without specifying its possible values.
  982. This results in an incomplete type, much like what you get if you write
  983. `struct foo' without describing the elements.  A later declaration
  984. which does specify the possible values completes the type.
  985.  
  986.    You can't allocate variables or storage using the type while it is
  987. incomplete.  However, you can work with pointers to that type.
  988.  
  989.    This extension may not be very useful, but it makes the handling of
  990. `enum' more consistent with the way `struct' and `union' are handled.
  991.  
  992. File: gcc.info,  Node: Function Names,  Prev: Incomplete Enums,  Up: C Extensions
  993.  
  994. Function Names as Strings
  995. =========================
  996.  
  997.    GNU CC predefines two string variables to be the name of the current
  998. function.  The variable `__FUNCTION__' is the name of the function as
  999. it appears in the source.  The variable `__PRETTY_FUNCTION__' is the
  1000. name of the function pretty printed in a language specific fashion.
  1001.  
  1002.    These names are always the same in a C function, but in a C++
  1003. function they may be different.  For example, this program:
  1004.  
  1005.      extern "C" {
  1006.      extern int printf (char *, ...);
  1007.      }
  1008.      
  1009.      class a {
  1010.       public:
  1011.        sub (int i)
  1012.          {
  1013.            printf ("__FUNCTION__ = %s\n", __FUNCTION__);
  1014.            printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
  1015.          }
  1016.      };
  1017.      
  1018.      int
  1019.      main (void)
  1020.      {
  1021.        a ax;
  1022.        ax.sub (0);
  1023.        return 0;
  1024.      }
  1025.  
  1026. gives this output:
  1027.  
  1028.      __FUNCTION__ = sub
  1029.      __PRETTY_FUNCTION__ = int  a::sub (int)
  1030.  
  1031. File: gcc.info,  Node: C++ Extensions,  Next: Trouble,  Prev: C Extensions,  Up: Top
  1032.  
  1033. Extensions to the C++ Language
  1034. ******************************
  1035.  
  1036.    The GNU compiler provides these extensions to the C++ language (and
  1037. you can also use most of the C language extensions in your C++
  1038. programs).  If you want to write code that checks whether these
  1039. features are available, you can test for the GNU compiler the same way
  1040. as for C programs: check for a predefined macro `__GNUC__'.  You can
  1041. also use `__GNUG__' to test specifically for GNU C++ (*note Standard
  1042. Predefined Macros: (cpp.info)Standard Predefined.).
  1043.  
  1044. * Menu:
  1045.  
  1046. * Naming Results::      Giving a name to C++ function return values.
  1047. * Min and Max::        C++ Minimum and maximum operators.
  1048. * Destructors and Goto:: Goto is safe to use in C++ even when destructors
  1049.                            are needed.
  1050. * C++ Interface::       You can use a single C++ header file for both
  1051.                          declarations and definitions.
  1052. * C++ Signatures::    You can specify abstract types to get subtype
  1053.              polymorphism independent from inheritance.
  1054.  
  1055. File: gcc.info,  Node: Naming Results,  Next: Min and Max,  Up: C++ Extensions
  1056.  
  1057. Named Return Values in C++
  1058. ==========================
  1059.  
  1060.    GNU C++ extends the function-definition syntax to allow you to
  1061. specify a name for the result of a function outside the body of the
  1062. definition, in C++ programs:
  1063.  
  1064.      TYPE
  1065.      FUNCTIONNAME (ARGS) return RESULTNAME;
  1066.      {
  1067.        ...
  1068.        BODY
  1069.        ...
  1070.      }
  1071.  
  1072.    You can use this feature to avoid an extra constructor call when a
  1073. function result has a class type.  For example, consider a function
  1074. `m', declared as `X v = m ();', whose result is of class `X':
  1075.  
  1076.      X
  1077.      m ()
  1078.      {
  1079.        X b;
  1080.        b.a = 23;
  1081.        return b;
  1082.      }
  1083.  
  1084.    Although `m' appears to have no arguments, in fact it has one
  1085. implicit argument: the address of the return value.  At invocation, the
  1086. address of enough space to hold `v' is sent in as the implicit argument.
  1087. Then `b' is constructed and its `a' field is set to the value 23.
  1088. Finally, a copy constructor (a constructor of the form `X(X&)') is
  1089. applied to `b', with the (implicit) return value location as the
  1090. target, so that `v' is now bound to the return value.
  1091.  
  1092.    But this is wasteful.  The local `b' is declared just to hold
  1093. something that will be copied right out.  While a compiler that
  1094. combined an "elision" algorithm with interprocedural data flow analysis
  1095. could conceivably eliminate all of this, it is much more practical to
  1096. allow you to assist the compiler in generating efficient code by
  1097. manipulating the return value explicitly, thus avoiding the local
  1098. variable and copy constructor altogether.
  1099.  
  1100.    Using the extended GNU C++ function-definition syntax, you can avoid
  1101. the temporary allocation and copying by naming `r' as your return value
  1102. as the outset, and assigning to its `a' field directly:
  1103.  
  1104.      X
  1105.      m () return r;
  1106.      {
  1107.        r.a = 23;
  1108.      }
  1109.  
  1110. The declaration of `r' is a standard, proper declaration, whose effects
  1111. are executed *before* any of the body of `m'.
  1112.  
  1113.    Functions of this type impose no additional restrictions; in
  1114. particular, you can execute `return' statements, or return implicitly by
  1115. reaching the end of the function body ("falling off the edge").  Cases
  1116. like
  1117.  
  1118.      X
  1119.      m () return r (23);
  1120.      {
  1121.        return;
  1122.      }
  1123.  
  1124. (or even `X m () return r (23); { }') are unambiguous, since the return
  1125. value `r' has been initialized in either case.  The following code may
  1126. be hard to read, but also works predictably:
  1127.  
  1128.      X
  1129.      m () return r;
  1130.      {
  1131.        X b;
  1132.        return b;
  1133.      }
  1134.  
  1135.    The return value slot denoted by `r' is initialized at the outset,
  1136. but the statement `return b;' overrides this value.  The compiler deals
  1137. with this by destroying `r' (calling the destructor if there is one, or
  1138. doing nothing if there is not), and then reinitializing `r' with `b'.
  1139.  
  1140.    This extension is provided primarily to help people who use
  1141. overloaded operators, where there is a great need to control not just
  1142. the arguments, but the return values of functions.  For classes where
  1143. the copy constructor incurs a heavy performance penalty (especially in
  1144. the common case where there is a quick default constructor), this is a
  1145. major savings.  The disadvantage of this extension is that you do not
  1146. control when the default constructor for the return value is called: it
  1147. is always called at the beginning.
  1148.  
  1149. File: gcc.info,  Node: Min and Max,  Next: Destructors and Goto,  Prev: Naming Results,  Up: C++ Extensions
  1150.  
  1151. Minimum and Maximum Operators in C++
  1152. ====================================
  1153.  
  1154.    It is very convenient to have operators which return the "minimum"
  1155. or the "maximum" of two arguments.  In GNU C++ (but not in GNU C),
  1156.  
  1157. `A <? B'
  1158.      is the "minimum", returning the smaller of the numeric values A
  1159.      and B;
  1160.  
  1161. `A >? B'
  1162.      is the "maximum", returning the larger of the numeric values A and
  1163.      B.
  1164.  
  1165.    These operations are not primitive in ordinary C++, since you can
  1166. use a macro to return the minimum of two things in C++, as in the
  1167. following example.
  1168.  
  1169.      #define MIN(X,Y) ((X) < (Y) ? : (X) : (Y))
  1170.  
  1171. You might then use `int min = MIN (i, j);' to set MIN to the minimum
  1172. value of variables I and J.
  1173.  
  1174.    However, side effects in `X' or `Y' may cause unintended behavior.
  1175. For example, `MIN (i++, j++)' will fail, incrementing the smaller
  1176. counter twice.  A GNU C extension allows you to write safe macros that
  1177. avoid this kind of problem (*note Naming an Expression's Type: Naming
  1178. Types.).  However, writing `MIN' and `MAX' as macros also forces you to
  1179. use function-call notation notation for a fundamental arithmetic
  1180. operation.  Using GNU C++ extensions, you can write `int min = i <? j;'
  1181. instead.
  1182.  
  1183.    Since `<?' and `>?' are built into the compiler, they properly
  1184. handle expressions with side-effects;  `int min = i++ <? j++;' works
  1185. correctly.
  1186.  
  1187. File: gcc.info,  Node: Destructors and Goto,  Next: C++ Interface,  Prev: Min and Max,  Up: C++ Extensions
  1188.  
  1189. `goto' and Destructors in GNU C++
  1190. =================================
  1191.  
  1192.    In C++ programs, you can safely use the `goto' statement.  When you
  1193. use it to exit a block which contains aggregates requiring destructors,
  1194. the destructors will run before the `goto' transfers control.  (In ANSI
  1195. C++, `goto' is restricted to targets within the current block.)
  1196.  
  1197.    The compiler still forbids using `goto' to *enter* a scope that
  1198. requires constructors.
  1199.  
  1200.